/**
 * 检疫申报
 * @constructor
 */
function QuarantineDeclaration() {
}

QuarantineDeclaration.init = function () {
    getAllCity();
    getAllCity2();
    // $("#text_ReportType").change(function() {
    //
    // });
    $('#tableList').bootstrapTable({
        url: '/quarantineDeclaration/tableSearch',
        method: 'post',
        striped : true, //是否显示行间隔色
        toolbar: "#toolbar",
        sidePagination: "true",
        dataField: "data",//这是返回的json数组的key.默认是"rows".这里只有前后端约定好就行
        showToggle : true, //是否显示详细视图和列表视图的切换按钮
        striped: true, // 是否显示行间隔色
        //search : "true",
        uniqueId: "id",
        pageList : [ 5, 10, 20,50,100],//可选择单页记录数
        pageSize: "10",
        pagination: true, // 是否分页
        sortable: true, // 是否启用排序
        sidePagination: 'server', // 设置为服务器端分页     客户端：client
        search:false,
        showColumns: true,
        showRefresh: true,
        showExport: true,
        //得到查询的参数
        queryParams: function (params) {
            //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            var query_params = {
                //********table的参数 不变
                pageSize: params.limit,                         //页面大小
                pageIndex: (params.offset / params.limit) + 1,   //页码
                sort: params.sort,      //排序列名
                sortOrder: params.order, //排位命令（desc，asc）
                //********
                //获取查询的对象，往下加入
                applicant: $('#search_Applicant').val(),
                reportType: $('#search_ReportType').val(),
                timeInterval: $('#search_TimeIntervale').val(), // 请求时向服务端传递的参数
            };
            return query_params;
        },
        columns: [
            {
                //field: 'Number',//可不加
                title: '序号',//标题  可不加
                align: "center",
                width: 40,
                formatter: function (value, row, index) {
                    var pageSize=$('#tableList').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                    var pageNumber=$('#tableList').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                    return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                }
            },
            { field: 'applicant', title: '申报单位',align: 'center'},
            { field: 'reportDate', title: '报检日期',align: 'center'},
            { title: '报检方式',align: 'center',
                formatter: function (value, row, index) {
                    let a = "";
                    if(row.reportType=='动物A'){
                        a="<span class=\"label label-success\">"+row.reportType+"</span>"
                    }else{
                        a="<span class=\"label label-danger\">"+row.reportType+"</span>"
                    }
                    return a;
                }
            },
            { field: 'applicantPhone', title: '单位联系电话',align: 'center'},
            { field: 'purchaserName', title: '购买人姓名',align: 'center'},
            { field: 'purchaserPhone', title: '购买人电话',align: 'center'},
            { field: 'animalType', title: '动物种类',align: 'center'},
            { field: 'purpose', title: '用途',align: 'center'},
            { field: 'number', title: '数量',align: 'center'},
            { field: 'unit', title: '单位',align: 'center'},
            { field: 'currentPosition', title: '当前定位',align: 'center'},
            { field: 'shipAddress', title: '启运地址',align: 'center'},
            { title: '到达地址',align: 'center',
                formatter: function (value, row, index) {
                    let a = "";
                    if(row.reportType=='动物A'){
                        a="<span>"+row.province+row.city+row.district+row.arrivalAddress+row.field+"</span>"
                    }else{
                        a="<span>"+row.city+row.district+row.township+row.arrivalAddress+row.field+"</span>"
                    }
                    return a;
                }
            },
            { field: 'livestockNo', title: '牲畜耳标号',align: 'center'},
            { field: 'httpLivestockPhoto', title: '牲畜状态照片',align: 'center',width: 200,
                formatter:function(value){
                    return "<img src=\""+value+"\" class=\"img-responsive\">";
                }
            },
            { field: 'httpCarPhoto', title: '车辆运载照片',align: 'center',width: 200,
                formatter:function(value){
                    return "<img src=\""+value+"\" class=\"img-responsive\">";
                }
            },
            { field: 'saleDate', title: '销售日期',align: 'center'},
            { field: 'carrier', title: '承运人',align: 'center'},
            { field: 'carrierPhone', title: '承运人电话',align: 'center'},
            { field: 'carNumber', title: '车牌号',align: 'center'},
            { field: 'disinfection', title: '承运工具消毒情况',align: 'center'},
            { field: 'carry', title: '运载方式',align: 'center'},
            { field: 'quarantineDate', title: '检疫日期',align: 'center'},
            { field: 'quarantineCode', title: '检疫证明码',align: 'center'},
            { title: '状态',align: 'center',
                formatter: function (value, row, index){
                    let a="";
                    if(row.state==0){
                        a="<span class=\"label label-info\">"+"待处理"+"</span>"
                    }else{
                        a="<span class=\"label label-warning\">"+"已处理"+"</span>"
                    }
                    return a;
                }
            },
            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    let optionHtml = "";
                    if(row.state==0){
                        optionHtml = optionHtml+"&nbsp<a class=\"btn btn-success btn-xs\"  href=\"javascript:void(0)\"  onclick='actionRecord(" + JSON.stringify(row) + ",\"edit\")' title=\"修改\" ><i class=\"fa fa-edit\"></i>修改</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
                        optionHtml = optionHtml + " <a class=\"btn btn-danger btn-xs\" href=\"javascript:void(0)\"  onclick='actionRecord(" + JSON.stringify(row) + ",\"delete\")'  title=\"删除\"><i class=\"fa fa-remove\"></i>删除</a>"
                    }else{
                        optionHtml = optionHtml + " <a class=\"btn btn-danger btn-xs\" ><i class=\"fa fa-remove\"></i>已处理,无法操作</a>"
                    }
                    return optionHtml;
                }
            }
        ]
    });
}
/**
 *时间选择器
 */
laydate.render({
    elem: '#text_SaleDate',
    theme: 'molv',
    type:"date",
});
laydate.render({
    elem: '#search_TimeIntervale',
    range: true,
});
//查询方法****************************
function doSearch() {
    $("#tableList").bootstrapTable("refreshOptions",{pageNumber:1});
}
//重置****************************
function doRest() {
    $("#search_Applicant").val("");
    $("#search_ReportType").val("");
    $("#search_TimeIntervale").val("");
    $("#tableList").bootstrapTable("refreshOptions",{pageNumber:1});
}
//增加方法****************************
var Action="";
var quarantineId=0;
var pxt="/quarantineDeclaration"; //控制器名称
function addRecord() {
    quarantineId=0;
    Action="add";
    $("#myform")[0].reset();
    document.getElementById("showImage").style.display = "none";
    document.getElementById("showImage2").style.display = "none";
    changme($('#text_ReportType'));
    $("#myModalAdd select").each(function ()
    {
        $(this).find("option:selected").removeAttr("selected");
    });

}
//增加/修改数据保存****************************
function saveRecord() {
    //创建传递的参数
    let province='';
    let city='';
    let district='';
    let township='';
    let arrivalAddress='';
    let field='';
    if($("#text_ReportType").val()=='动物A'){
        if(!validateForm()) return false;
        provinceIndex=document.getElementById("text_Province").selectedIndex;
        cityIndex=document.getElementById("text_City").selectedIndex;
        districtIndex=document.getElementById("text_District").selectedIndex;
        province = document.getElementById("text_Province").options[provinceIndex].text;
        city = document.getElementById("text_City").options[cityIndex].text;
        district =document.getElementById("text_District").options[districtIndex].text;
        arrivalAddress = $("#text_ArrivalAddress").val()
        field = $("#text_Field").val()
    }else{
        if(!validateForm2()) return false;
        cityIndex=document.getElementById("text_City2").selectedIndex;
        districtIndex=document.getElementById("text_District2").selectedIndex;
        townshipIndex=document.getElementById("text_Township").selectedIndex;
        city = document.getElementById("text_City2").options[cityIndex].text;
        district = document.getElementById("text_District2").options[districtIndex].text;
        township =document.getElementById("text_Township").options[townshipIndex].text;
        arrivalAddress = $("#text_ArrivalAddress2").val()
        field = $("#text_Field2").val()
    }
    var postdata = {
        quarantineId : quarantineId,
        action:Action,
        reportType: $("#text_ReportType").val(),  //报检方式
        applicantPhone: $("#text_ApplicantPhone").val(),  //单位联系电话
        purchaserName: $("#text_PurchaserName").val(),  //购买人姓名
        purchaserPhone: $("#text_PurchaserPhone").val(),  //购买人电话
        animalType: $("#text_AnimalType").val(),    //动物种类
        purpose: $("#text_Purpose").val(),    //用途
        number: $("#text_Number").val(),   //数量
        unit: $("#text_Unit").val(),    //单位
        currentPosition: $("#text_CurrentPosition").val(),  //当前定位
        shipAddress: $("#text_ShipAddress").val(),    //启运地址
        province:province,  //省
        city:city,  //市
        district:district,  //区县
        township:township,  //乡镇
        arrivalAddress:arrivalAddress,  //详细地址
        field:field,    //场地
        livestockNo: $("#text_LivestockNo").val(),    //牲畜耳标号
        livestockPhoto: livestockPhoto,    //牲畜状态照片
        carPhoto: carPhoto,    //车辆运载照片
        saleDate: $("#text_SaleDate").val(),    //销售日期
        carrier: $("#text_Carrier").val(),    //承运人
        carrierPhone: $("#text_CarrierPhone").val(),    //承运人电话
        carNumber: $("#text_CarNumber").val(),    //车牌号
        disinfection: $("#text_Disinfection").val(),    //承运工具消毒情况
        carry: $("input[type='radio']:checked").val(),    //运载方式
    };
    if($("#text_ReportType").val()=='动物B'){
        delete carry;
    }
    //发送异步请求到后台保存用户数据
    $.ajax({
        url:pxt+"/save",
        type:"post",
        data:JSON.stringify(postdata),
        contentType:"application/json",
        dataType:"json",
        success:function(data){
            if (data.code === "200") {
                $('#myModalAdd').modal('hide')
                doSearch();
                swal("操作成功!", "请继续操作", "success");
            } else {
                swal("操作失败!", "请重试", "error");
            }
        }
    });
}

//操作相关方法****************************
function actionRecord(data,type) {
    if(type=="edit")
    {
        //修改
        quarantineId=data.quarantineId;
        Action="edit";
        $("#myform")[0].reset();
        $("#save").removeAttr("disabled");
        WriteData(data)
        document.getElementById("showImage").style.display = "block";
        document.getElementById("showImage2").style.display = "block";
        $('#myModalAdd').modal('show')
    }
    else
    {
        //删除
        swal({
            title: "确认是否删除",
            text: "是否确认要删除该条记录？",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "删除",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {
            //点击删除之后此处进行传递后台
            $.ajax({
                type: "delete",
                url: pxt+"/deleteById/"+data.quarantineId,
                dataType : "json",
                contentType: "application/json",
                success: function (data, status) {
                    if (data.code == "200") {
                        doSearch();
                        swal("删除成功!", "请继续操作", "success");
                    }
                    else{
                        swal("删除失败!", "请重试", "error");
                    }
                }
            });

        });
    }
}

//给控件赋值****************************
function WriteData(data) {
    $("#text_ReportType").val(data.reportType); //报检方式
    $("#text_ApplicantPhone").val(data.applicantPhone); //单位联系电话
    $("#text_PurchaserName").val(data.purchaserName);   //购买人姓名
    $("#text_PurchaserPhone").val(data.purchaserPhone); //购买人电话
    $("#text_AnimalType").val(data.animalType); //动物种类
    $("#text_Purpose").val(data.purpose);   //用途
    $("#text_Number").val(data.number); //数量
    $("#text_Unit").val(data.unit); //单位
    $("#text_CurrentPosition").val(data.currentPosition);   //当前定位
    $("#text_ShipAddress").val(data.shipAddress);   //启运地址
    if (data.reportType == '动物A') {
        //显示隐藏
        document.getElementById("A").style.display = "block";
        document.getElementById("B").style.display = "none";
        document.getElementById("C").style.display = "block";
        document.getElementById("D").style.display = "block";
        document.getElementById("E").style.display = "block";

        console.log("data",data)
        document.getElementById("text_Province").options[document.getElementById("text_Province").selectedIndex].text = data.province;   //省
        getAllCity(data.city);   //市

        getAllDistrict1(data.district);   //区县
        $("#text_ArrivalAddress").val(data.arrivalAddress);   //详细地址
        $("#text_Field").val(data.field);   //场地
        $("input:radio[value="+data.carry+"]").attr('checked','true');  //运载方式
    } else {
        //显示隐藏
        //模态框显示
        document.getElementById("A").style.display = "none";
        document.getElementById("B").style.display = "block";
        document.getElementById("C").style.display = "none";
        document.getElementById("D").style.display = "none";
        document.getElementById("E").style.display = "none";

        console.log("data",data)
        getAllCity2(data.city);   //市
        getAllDistrict2(data.district,);   //区县
        getTownship(data.township);   //乡镇
        $("#text_ArrivalAddress2").val(data.arrivalAddress);   //详细地址
        $("#text_Field2").val(data.field);   //场地
    }
    $("#text_LivestockNo").val(data.livestockNo);   //耳标号
    livestockPhoto = data.livestockPhoto; //完整路径牲畜状态照片
    carPhoto = data.carPhoto; //完整车辆运载照片
    $("#showImage").attr("src",data.httpLivestockPhoto); //牲畜状态照片
    $("#showImage2").attr("src",data.httpCarPhoto); //车辆运载照片
    $("#text_SaleDate").val(data.saleDate); //销售日期
    $("#text_Carrier").val(data.carrier);   //承运人
    $("#text_CarrierPhone").val(data.carrierPhone);   //承运人电话
    $("#text_CarNumber").val(data.carNumber);   //车牌号
    $("#text_Disinfection").val(data.disinfection);   //承运工具消毒情况
    }
//绑定下拉****************************
    function getAllCity(type) {
        $.ajax({
            type: "get",
            url: "/city/getAllCity",
            dataType: "json",
            contentType: "application/json",
            async: false,
            success: function (data, status) {
                //清空
                $("#text_City").empty();
                //将城市赋值给下拉列表
                $("#text_City").append("<option value=''>请选择地市</option>");
                $.each(data, function (index, value) {
                    if(value.city_name==type){
                        $("#text_City").append("<option value='" + value.city_id + "' selected>" + value.city_name + "</option>");
                    }else{
                        $("#text_City").append("<option value='" + value.city_id + "'>" + value.city_name + "</option>");
                    }
                })
            }
        });
    }

     function getAllCity2(type) {
    $.ajax({
        type: "get",
        url: "/city/getAllCity",
        dataType: "json",
        contentType: "application/json",
        async: false,
        success: function (data, status) {
            //清空
            $("#text_City2").empty();
            //将城市赋值给下拉列表
            $("#text_City2").append("<option value=''>请选择地市</option>");
            $.each(data, function (index, value) {
                if(value.city_name==type){
                    $("#text_City2").append("<option value='" + value.city_id + "' selected>" + value.city_name + "</option>");
                }else{
                    $("#text_City2").append("<option value='" + value.city_id + "'>" + value.city_name + "</option>");
                }
            })
        }
    });
}

    function getAllDistrict1(type) {
        console.log("进入点击事件",$("#text_City").val())
        $.ajax({
            type: "get",
            url: "/district/getDistrictByCity?city_id=" + $("#text_City").val(),
            dataType: "json",
            contentType: "application/json",
            success: function (data, status) {
                //清空
                $("#text_District").empty();
                //将城市赋值给下拉列表
                $("#text_District").append("<option value=''>请选择区县</option>");
                $.each(data, function (index, value) {
                    if(value.district_name==type){
                        $("#text_District").append("<option value='" + value.district_id + "' selected>" + value.district_name + "</option>");
                    }else{
                        $("#text_District").append("<option value='" + value.district_id + "'>" + value.district_name + "</option>");
                    }
                })

            }
        });
    }

    function getAllDistrict2(type) {
        $.ajax({
            type: "get",
            url: "/district/getDistrictByCity?city_id=" + $("#text_City2").val(),
            dataType: "json",
            contentType: "application/json",
            async: false,
            success: function (data, status) {
                //清空
                $("#text_District2").empty();
                //将城市赋值给下拉列表
                $("#text_District2").append("<option value=''>请选择区县</option>");
                $.each(data, function (index, value) {
                    if(value.district_name==type){
                        $("#text_District2").append("<option value='" + value.district_id + "' selected>" + value.district_name + "</option>");
                    }else{
                        $("#text_District2").append("<option value='" + value.district_id + "'>" + value.district_name + "</option>");
                    }
                })
            }
        });
    }

    function getTownship(type) {
    console.log("进入乡镇方法",$("#text_District2").val())
        $.ajax({
            type: "get",
            url: "/town/getTownByDistrict?district_id=" + $("#text_District2").val(),
            dataType: "json",
            contentType: "application/json",
            success: function (data, status) {
                console.log("获得乡镇信息",data)
                //清空
                $("#text_Township").empty();
                //将城市赋值给下拉列表
                $("#text_Township").append("<option value=''>请选择乡镇</option>");
                $.each(data, function (index, value) {
                    if(value.town__name==type){
                        $("#text_Township").append("<option value='" + value.town_id + "' selected>" + value.town__name + "</option>");
                    }else{
                        $("#text_Township").append("<option value='" + value.town_id + "'>" + value.town__name + "</option>");
                    }
                })
            }
        });
    }

//图片上传
    var livestockPhoto = "";  //牲畜状态照片
    var carPhoto = "";    //车辆运载照片
//上传****************************
    function ImportShipmentStatusList1() {
        console.log("进入图片上传方法")
        var upname = "text_LivestockPhoto";
        if ($("#" + upname).val() == "") {
            alert("请选择上传图片");
            return;
        }
        $.ajaxFileUpload({
            url: pxt + '/uploadImages',
            secureuri: false,
            fileElementId: upname,
            dataType: 'json',
            success: function (data, status) {
                livestockPhoto = data.url;
                getImage(data.httpUrl);
                //隐藏文件选择
                $("#uploadImages").css("display","none");
                //图片回显
                $("#showImage").css("display","");
                $("#showImage").attr("src",data.httpUrl);
            },
            error: function (data, status, e) {
                console.log("上传图片失败", e);
            }
        });
    }

    function ImportShipmentStatusList2() {
        console.log("进入图片上传方法")
        var upname = "text_LivestockPhoto";
        if ($("#" + upname).val() == "") {
            alert("请选择上传图片");
            return;
        }
        $.ajaxFileUpload({
            url: pxt + '/uploadImages',
            secureuri: false,
            fileElementId: upname,
            dataType: 'json',
            success: function (data, status) {
                carPhoto = data.url;
                getImage(data.httpUrl);
                //隐藏文件选择
                $("#uploadImages2").css("display","none");
                //图片回显
                $("#showImage2").css("display","");
                $("#showImage2").attr("src",data.httpUrl);
            },
            error: function (data, status, e) {
                console.log("上传图片失败", e);
            }
        });
    }

    function getImage(url) {
        var html = "";
        html = html + "<div class=\"col-lg-9\">";
        html = html + "<div class=\"form-group\" style='width:420px; height:250px'>";
        html = html + "<img style='width:420px; height:250px' src=\"" + url + "\" />";
        html = html + "</div>";
        html = html + "</div>";
    }
function validateForm() {
    //validate方法参数可选
    return $("#myform").validate({
        rules: {
            text_ApplicantPhone: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_PurchaserName: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_PurchaserPhone: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_Number: {
                required: true,//必填
                minlength: 1, //最少1个字符
                number: true, //必须是数字
            },
            text_CurrentPosition: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_ShipAddress: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_City: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_District: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_ArrivalAddress: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_LivestockNo: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_SaleDate: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_Carrier: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_CarrierPhone: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_CarNumber: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_Disinfection: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            category: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
        },
        //错误信息提示
        messages: {
            text_ApplicantPhone: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_PurchaserName: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_PurchaserPhone: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_Number: {
                required: "(必填)",
                minlength: "最少1位",
                number: "必须输入数字",
            },
            text_CurrentPosition: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_ShipAddress: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_City: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_District: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_ArrivalAddress: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_LivestockNo: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_SaleDate: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_Carrier: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_CarrierPhone: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_CarNumber: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_Disinfection: {
                required: "(必填)",
                minlength: "最少1位",
            },
            category: {
                required: "(必填)",
                minlength: "最少1位",
            },
        },
    }).form();
}
function validateForm2() {
    //validate方法参数可选
    return $("#myform").validate({
        rules: {
            text_ApplicantPhone: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_PurchaserName: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_PurchaserPhone: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_Number: {
                required: true,//必填
                minlength: 1, //最少1个字符
                number: true, //必须是数字
            },
            text_CurrentPosition: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_ShipAddress: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_City2: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_District2: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_Township: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_ArrivalAddress: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_LivestockNo: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
            text_SaleDate: {
                required: true,//必填
                minlength: 1, //最少1个字符
            },
        },
        //错误信息提示
        messages: {
            text_ApplicantPhone: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_PurchaserName: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_PurchaserPhone: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_Number: {
                required: "(必填)",
                minlength: "最少1位",
                number: "必须输入数字",
            },
            text_CurrentPosition: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_ShipAddress: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_City2: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_District2: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_Township: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_ArrivalAddress: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_LivestockNo: {
                required: "(必填)",
                minlength: "最少1位",
            },
            text_SaleDate: {
                required: "(必填)",
                minlength: "最少1位",
            },
        },
    }).form();
}

function changme(me) {
    if ($(me).val() == "动物A") {
        document.getElementById("A").style.display = "block";
        document.getElementById("B").style.display = "none";
        document.getElementById("C").style.display = "block";
        document.getElementById("D").style.display = "block";
        document.getElementById("E").style.display = "block";
    }else if($(me).val() == "动物B"){
        document.getElementById("A").style.display = "none";
        document.getElementById("B").style.display = "block";
        document.getElementById("C").style.display = "none";
        document.getElementById("D").style.display = "none";
        document.getElementById("E").style.display = "none";
    }
}